home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _4883C0350E644B4DAD88DF07E3BE3CD1 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.4 KB  |  46 lines

  1. // ===============================================================
  2. // Vertex Program: 
  3. // Description: 
  4. // Last Update: 14/08/2003
  5. // Coder: Andrey Honich
  6. // ===============================================================
  7.  
  8.       #include "../CGVPMacro.csi"
  9.  
  10.       VS20Only
  11.  
  12.       VertAttributes { POSITION_3 TEXCOORD0_2 TANG_3X3 }
  13.       MainInput { VIEWPROJ_MATRIX, LIGHT_POS, CAMERA_POS, ATTEN, LIGHT_MATRIX }
  14.       DeclarationsScript
  15.       {
  16.         IN_T0_TANG
  17.         OUT_T0_T1_LVT2_HVT3_T4_C0
  18.       }
  19.       PositionScript = PosCommon
  20.       CoreScript
  21.       {
  22.         OUT.Tex0.xy = IN.TexCoord0.xy;
  23.         OUT.Tex1.xy = IN.TexCoord0.xy;
  24.         OUT.Tex4 = mul(LightMatrix, vPos);
  25.  
  26.         TANG_MATR
  27.  
  28.         float3 lVec = LightPos.xyz - vPos.xyz;
  29.         float3 lightVec = mul(objToTangentSpace, lVec);          
  30.         OUT.LightVector.xyz = lightVec.xyz;          
  31.  
  32.         // store normalized light vector
  33.         float fiSqDist = rsqrt(dot(lVec, lVec));        
  34.         OUT.Color.xyz = PROC_ATTENVERT;
  35.  
  36.         // store normalized light vector
  37.         float3 vVec = CameraPos.xyz - vPos.xyz;
  38.         float3 viewVec = mul(objToTangentSpace, vVec);
  39.  
  40.         // compute half angle vector
  41.         float3 halfAngleVector = normalize(viewVec) + normalize(lightVec);
  42.  
  43.         // transform light vector from object space to tangent space and pass it as a tex coords
  44.         OUT.HalfAngleVector.xyz = halfAngleVector;
  45.       }
  46.